//
//  ShengGaoPopView.m
//  markmap
//
//  Created by 甘世清 on 2024/7/18.
//

#import "ShengGaoPopView.h"

@implementation ShengGaoPopView

- (void)SQ_UIViewForSelfView{
    self.backgroundColor = SQColor(@"#414141");
    self.layer.cornerRadius = 25;
    
    UILabel * num4 = [[UILabel alloc]init];
    num4.text = SQNSLocalString(@"身高");
    num4.font = FONT_MEDIUM(17);
    num4.textColor = UIColor.whiteColor;
    [self addSubview:num4];
    [num4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(35);
        make.top.equalTo(self).offset(28);
    }];
    [self addSubview:self.shengaoLabel];
    [self.shengaoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(num4);
        make.right.equalTo(self.mas_right).offset(-35);
    }];
    
    [self addSubview:self.ttrange];
    [self.ttrange mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.width.mas_equalTo(SCREEN_WIDETH-32);
        make.top.equalTo(num4.mas_bottom).offset(10);
        make.height.mas_equalTo(60);
    }];
   
}
- (void)setNumber:(NSString *)number{
    _number = number;
    self.shengaoLabel.text = number;
    if (self.numberBlock) {
        self.numberBlock(self.shengaoLabel.text);
    }
    NSString * num = [number stringByReplacingOccurrencesOfString:@"CM" withString:@""];
    self.ttrange.selectedMaximum = [num integerValue];
}
/**
 * Called when the RangeSlider values are changed
 */
-(void)rangeSlider:(TTRangeSlider *)sender didChangeSelectedMinimumValue:(float)selectedMinimum andMaximumValue:(float)selectedMaximum{
    self.shengaoLabel.text = [NSString stringWithFormat:@"%.fCM",selectedMaximum];
    if (self.numberBlock) {
        self.numberBlock(self.shengaoLabel.text);
    }
}
- (UILabel *)shengaoLabel{
    if (!_shengaoLabel) {
        _shengaoLabel = [[UILabel alloc]init];
        _shengaoLabel.font = FONT_MEDIUM(16);
        _shengaoLabel.textColor = UIColor.whiteColor;
        _shengaoLabel.text = @"170CM";
    }
    return _shengaoLabel;
}
- (TTRangeSlider *)ttrange{
    if (!_ttrange) {
        _ttrange = [[TTRangeSlider alloc]init];
        _ttrange.maxValue = 230;
        _ttrange.minValue = 130;
        _ttrange.selectedMaximum = 170;
        _ttrange.hideLabels = YES;
        _ttrange.step = 1;
        _ttrange.lineHeight = 6;
        _ttrange.disableRange = YES;
        _ttrange.tintColor = UIColor.whiteColor;
        _ttrange.handleDiameter = 30;
        _ttrange.delegate = self;
        _ttrange.tintColorBetweenHandles = UIColor.whiteColor;
      
    }
    return _ttrange;
}

@end
